import dash
from dash import html, dcc
from dash.dependencies import Input, Output

# 创建Dash应用
app = dash.Dash(__name__)

# 定义布局
app.layout = html.Div(
    [
        html.H1("选择显示的数据"),
        dcc.RadioItems(
            id="id_radio_mode",
            options=[
                {"label": "模式1", "value": "mode1"},
                {"label": "模式2", "value": "mode2"},
                {"label": "模式3", "value": "mode3"},
            ],
            value="mode1",
        ),
        html.Div(
            id="id_show_mode"
        )
    ]
)

# 定义回调函数
@app.callback(Output("id_show_mode", "children"), Input("id_radio_mode", "value"))
def update_mode(select_mode):
    text = f"选择模式: {select_mode}"
    return text


if __name__ == "__main__":
    app.run(debug=True, port=8090)
